<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="../Skin/Plane/css/index.css">
<script type="text/javascript" src="../Htc/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../Htc/echarts.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	//若当前用户没有修改过密码则弹出修改密码
	var isEditpsw=${isEditpsw};
	if(isEditpsw==1){openWin("../Login/Editpsw.html","修改密码");}

	option = {
		title: {
			text: '前五产品销量'
		},
		color: [
			'#68a218','#81b737','#99c65a','#b1d186','#d4ebb4'
		],
		backgroundColor:"#fff",
		tooltip : {
			trigger: 'axis',
			axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
			}
		},
		legend: {
			data: [${legend}]
		},
		grid: {
			left: '10px',
			right: '20px',
			bottom: '10px',
			containLabel: true,
			backgroundColor:"#fff"
		},
		xAxis:  {
			type: 'value'
		},
		yAxis: {
			type: 'category',
			data: [${category}]
		},
		series: [
			<c:forEach items="${data}" var="dr"  varStatus="i">
			<c:if test="${i.index>0}">,</c:if>{
				name: '${dr.key}',
				type: 'bar',
				stack: '总量',
				label: {
					normal: {
						show: true,
						position: 'insideRight'
					}
				},
				data: [${dr.value}]
			}
			</c:forEach>
		]
	};
	$("#chart").height($("body").height()-250);
	var barChart = echarts.init(document.getElementById('chart'));
	barChart.setOption(option);

	RefreshData();
	setInterval("RefreshData()",300000);
	setInterval("ChangeColor()", 400);
});
 function openWin(url, name) {
 	if(typeof parent.AddWin == 'function') {
		parent.AddWin(url, name);
	}else if(typeof parent.parent.AddWin == 'function') {
		parent.parent.AddWin(url, name);
   }
}
function RefreshData()
{
	$.ajax({
		type: 'POST',
		url: "/Sys/IndexSum.Data",
		dataType: "json",
		success: function( data ) {
			if(data.code=="0000")
			{
				var tab=false;
				for(var p in data.data){
					var val=$("#"+p).html();
					if(val!=data.data[p]){
						tab=true;
						if(changeIds.indexOf("lab_"+p+",")==-1) changeIds+="lab_"+p+",";
						$("#"+p).html(data.data[p]);
					}
				}
				if(tab&&Player.controls) Player.controls.play();
			}
		}
	});
}
var changeIds="";
function ChangeColor() {
	if(changeIds=="") return;
	var arr=changeIds.split(",");
	for(var p in arr) if(arr[p]!="") $("#"+arr[p]).toggleClass("red");
}
function ChangeColorMove(id) {
	changeIds=changeIds.replace(id+",","");
	$("#"+id).removeClass("red");
}
</script>
</head>
  <body>
  <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td width="60%">
  	<div id="todo">
		<div class="title">待办事项</div>
		<div class="item" onclick="ChangeColorMove('lab_todo1');openWin('../Main/Manager.html?type=Order','发货管理')"><div class="num" id="todo1">0</div><span id="lab_todo1">待发货</span></div>
		<div class="item" onclick="ChangeColorMove('lab_todo2');openWin('../Main/Manager.html?type=ReturnGoods&status=10','待审核')"><div class="num" id="todo2">0</div><span id="lab_todo2">待审核</span></div>
		<div class="item" onclick="ChangeColorMove('lab_todo3');openWin('../Main/Manager.html?type=ReturnGoods&status=13','待收货')"><div class="num" id="todo3">0</div><span id="lab_todo3">待收货</span></div>
		<div class="item" onclick="ChangeColorMove('lab_todo4');openWin('../Main/Manager.html?type=ReturnGoods&status=14','待退款')"><div class="num" id="todo4">0</div><span id="lab_todo4">待退款</span></div>
		<div class="item" onclick="ChangeColorMove('lab_todo5');openWin('../Main/Manager.html?type=OrderDetailAppeal','退货申诉')"><div class="num" id="todo5">0</div><span id="lab_todo5">申诉中</span></div>
	</div>
	  </td><td width="40%">
  	<div id="orderSum">
		<div class="title">订单汇总</div>
		<div class="item">当日<span class="num" id="amount1">0</span></div>
		<div class="item">当月<span class="num" id="amount2">0</span></div>
		<div class="item">累计<span class="num" id="amount3">0</span></div>
	</div>
  </td></tr></table>
  	<div id="chart" style="width: 100%;"></div>
	  <OBJECT id="Player" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width=0 height=0 >
		  <param name="URL" value="../Resource/message.wma" />
		  <param name="AutoStart" value="false" />
	  </OBJECT>
  </body>
</html>
